﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Input;
using System.Windows.Media;
using Trackr.Helpers;

namespace Trackr.ViewModel
{
	public class NotificationViewModel<T> : BaseViewModel<T> where T : Window
	{
		private DateTime _currentDate = DateTime.Now;
		private bool _timeOut;

		public NotificationViewModel(T view)
		{
			View = view;
			CurrentApp.TimeElapsed += (o) =>
			{
				Dispatcher.Invoke(() =>
				{
					this.View.Show();
				});
			};
			CurrentApp.TimeOut += (o) =>
			{
				Dispatcher.Invoke(() =>
				{
					Core.Trackr.Instance.StopCurrentTimeItem();
					_timeOut = true;
					//this.View.Hide();
					CurrentApp.StopTimeOutTimer();
					CurrentApp.StopTimer();
				});
			};
		}
		#region properties
		#endregion properties
		#region commands
		public ICommand SaveTask
		{
			get
			{
				return Execute("SaveTask", (obj) =>
				{
					string task = obj as string;
					if (string.IsNullOrWhiteSpace(task))
						return;
					Core.Trackr.Instance.AddNew(task);
					Dispatcher.Invoke(() =>
					{
						CurrentApp.StopTimeOutTimer();
						CurrentApp.StartTimer();
						this.View.Hide();
					});
				});
			}
		}

		#endregion commands
	}
}